﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace syc.Store.报表
{
    public partial class 原料收拨平衡表 : System.Web.UI.Page
    {
       
        protected int yNum;
        protected int yjgNum;
        protected int tNum;
        protected int tjgNum;

        protected int ydclNum;
        protected int yjgdclNum;

        protected int tdclNum;
        protected int tjgdclNum;

        protected int tn80Num;
        protected int tn80dclNum;

        protected string[] 油管供货单位=new string[25];
        protected double[] 油管个单位期初库存库量 = new double[25];
        protected double[] 油管个单位本期入库量 = new double[25];
        protected double[] 二分厂油管个单位本期出库量 = new double[25];
        protected double[] 五分厂油管个单位本期出库量 = new double[25];
        protected double[] 合计油管个单位本期出库量 = new double[25];
        protected double 二分厂油管个单位本期出库量累计 =0;
        protected double 五分厂油管个单位本期出库量累计 = 0;
        
        protected double 油管期初库存量;
        protected double 油管本期入库量;
        protected double 油管本期出库量;

        protected string[] 套管供货单位 = new string[25];
        protected double[] 套管个单位期初库存库量 = new double[25];
        protected double[] 套管个单位本期入库量 = new double[25];
        protected double[] 一分厂套管个单位本期出库量 = new double[25];
        protected double[] 二分厂套管个单位本期出库量 = new double[25];
        protected double[] 合计套管个单位本期出库量 = new double[25];
        protected double 一分厂套管个单位本期出库量累计 = 0;
        protected double 二分厂套管个单位本期出库量累计 = 0;

        protected double 套管期初库存量;
        protected double 套管本期入库量;
        protected double 套管本期出库量;

        protected string[] 油管接箍供货单位 = new string[25];
        protected double[] 油管接箍个单位期初库存库量 = new double[25];
        protected double[] 油管接箍个单位本期入库量 = new double[25];
        protected double[] 三分厂油管接箍个单位本期出库量 = new double[25];
        protected double[] 合计油管接箍个单位本期出库量 = new double[25];
        protected double 三分厂油管接箍个单位本期出库量累计 = 0;


        protected double 油管接箍期初库存量;
        protected double 油管接箍本期入库量;
        protected double 油管接箍本期出库量;

        protected string[] 套管接箍供货单位 = new string[25];
        protected double[] 套管接箍个单位期初库存库量 = new double[25];
        protected double[] 套管接箍个单位本期入库量 = new double[25];
        protected double[] 三分厂套管接箍个单位本期出库量 = new double[25];
        protected double[] 合计套管接箍个单位本期出库量 = new double[25];
        protected double 三分厂套管接箍个单位本期出库量累计 = 0;


        protected double 套管接箍期初库存量;
        protected double 套管接箍本期入库量;
        protected double 套管接箍本期出库量;
        //待处理油管
        protected string[] 待处理油管供货单位 = new string[25];
        protected double[] 待处理油管个单位期末库存库量 = new double[25];
        protected double[] 待处理油管个单位本期入库量 = new double[25];
        protected double[] 二分厂待处理油管个单位本期出库量 = new double[25];
        protected double[] 五分厂待处理油管个单位本期出库量 = new double[25];
        protected double[] 合计待处理油管个单位本期出库量 = new double[25];
        protected double 二分厂待处理油管个单位本期出库量累计 = 0;
        protected double 五分厂待处理油管个单位本期出库量累计 = 0;

        protected double 待处理油管期末库存量;
        protected double 待处理油管本期入库量;
        protected double 待处理油管本期出库量;
        //待处理油管接箍
        protected string[] 待处理油管接箍供货单位 = new string[25];
        protected double[] 待处理油管接箍个单位期末库存库量 = new double[25];
        protected double[] 待处理油管接箍个单位本期入库量 = new double[25];
        protected double[] 三分厂待处理油管接箍个单位本期出库量 = new double[25];
        protected double[] 合计待处理油管接箍个单位本期出库量 = new double[25];
        protected double 三分厂待处理油管接箍个单位本期出库量累计 = 0;

        protected double 待处理油管接箍期末库存量;
        protected double 待处理油管接箍本期入库量;
        protected double 待处理油管接箍本期出库量;

        //待处理套管
        protected string[] 待处理套管供货单位 = new string[25];
        protected double[] 待处理套管个单位期末库存库量 = new double[25];
        protected double[] 待处理套管个单位本期入库量 = new double[25];
        protected double[] 二分厂待处理套管个单位本期出库量 = new double[25];
        protected double[] 一分厂待处理套管个单位本期出库量 = new double[25];
        protected double[] 合计待处理套管个单位本期出库量 = new double[25];
        protected double 二分厂待处理套管个单位本期出库量累计 = 0;
        protected double 一分厂待处理套管个单位本期出库量累计 = 0;

        protected double 待处理套管期末库存量;
        protected double 待处理套管本期入库量;
        protected double 待处理套管本期出库量;
        //待处理套管接箍
        protected string[] 待处理套管接箍供货单位 = new string[25];
        protected double[] 待处理套管接箍个单位期末库存库量 = new double[25];
        protected double[] 待处理套管接箍个单位本期入库量 = new double[25];
        protected double[] 三分厂待处理套管接箍个单位本期出库量 = new double[25];
        protected double[] 合计待处理套管接箍个单位本期出库量 = new double[25];
        protected double 三分厂待处理套管接箍个单位本期出库量累计 = 0;

        protected double 待处理套管接箍期末库存量;
        protected double 待处理套管接箍本期入库量;
        protected double 待处理套管接箍本期出库量;
        //套管N80
        protected string[] 套管N80供货单位 = new string[25];
        protected double[] 套管N80个单位期初库存库量 = new double[25];
        protected double[] 套管N80个单位本期入库量 = new double[25];
        protected double[] 一分厂套管N80个单位本期出库量 = new double[25];
        protected double[] 二分厂套管N80个单位本期出库量 = new double[25];
        protected double[] 合计套管N80个单位本期出库量 = new double[25];
        protected double 一分厂套管N80个单位本期出库量累计 = 0;
        protected double 二分厂套管N80个单位本期出库量累计 = 0;

        protected double 套管N80期初库存量;
        protected double 套管N80本期入库量;
        protected double 套管N80本期出库量;
        //待处理套管N80
        protected string[] 待处理套管N80供货单位 = new string[25];
        protected double[] 待处理套管N80个单位期末库存库量 = new double[25];
        protected double[] 待处理套管N80个单位本期入库量 = new double[25];
        protected double[] 二分厂待处理套管N80个单位本期出库量 = new double[25];
        protected double[] 一分厂待处理套管N80个单位本期出库量 = new double[25];
        protected double[] 合计待处理套管N80个单位本期出库量 = new double[25];
        protected double 二分厂待处理套管N80个单位本期出库量累计 = 0;
        protected double 一分厂待处理套管N80个单位本期出库量累计 = 0;

        protected double 待处理套管N80期末库存量;
        protected double 待处理套管N80本期入库量;
        protected double 待处理套管N80本期出库量;
     

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Year0.SelectedValue = DateTime.Today.Year.ToString();
                this.Month0.SelectedValue = DateTime.Today.Month.ToString();                
            }
            Button_Query_Click(null, null);
        }

      

        protected void Button_Query_Click(object sender, EventArgs e)
        {           
            SqlConnection Conn = new SqlConnection();
            Conn.ConnectionString = ConfigurationManager.ConnectionStrings["SCMConnectionString1"].ConnectionString;
            Conn.Open();
            SqlCommand Cmd = new SqlCommand();
            Cmd.Connection = Conn;
           //
          string sql= @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料本期收入(@年度,@月份,1,原料供货单位.ID),dbo.供货原料期初库存(@年度,@月份,1,原料供货单位.ID),[dbo].[分厂原料本期发出](@年度,@月份,1,原料供货单位.ID,2),[dbo].[分厂原料本期发出](@年度,@月份,1,原料供货单位.ID,5) from 原料入出库 inner join 原料供货单位 on 原料供货单位.ID=原料入出库.单位ID where 原料ID=1 and 入出=0 and 日期 between @yc and @ym 
                 ";
          sql = sql.Replace("@年度", this.Year0.SelectedValue);
          sql = sql.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText=sql;
            SqlDataReader Reader = Cmd.ExecuteReader();
            yNum = 0;
            while (Reader.Read())
            {             
                油管供货单位[yNum] = Reader.GetString(0);
                油管个单位本期入库量[yNum] = Reader.GetDouble(1);
                油管个单位期初库存库量[yNum] = Reader.GetDouble(2);
                二分厂油管个单位本期出库量[yNum] = Reader.GetDouble(3);
                五分厂油管个单位本期出库量[yNum] = Reader.GetDouble(4);
                二分厂油管个单位本期出库量累计 += 二分厂油管个单位本期出库量[yNum];
                五分厂油管个单位本期出库量累计 += 五分厂油管个单位本期出库量[yNum];
                合计油管个单位本期出库量[yNum] = 二分厂油管个单位本期出库量[yNum] + 五分厂油管个单位本期出库量[yNum];
          
                yNum++;
            }
            Reader.Close();
            string sql1 = @"            
            select dbo.原料期初库存(@年度,@月份,1),dbo.原料本期收入(@年度,@月份,1),dbo.原料本期发出(@年度,@月份,1)";
            sql1 = sql1.Replace("@年度", this.Year0.SelectedValue);
            sql1 = sql1.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql1;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                油管期初库存量 = Reader.GetDouble(0);
                油管本期入库量 = Reader.GetDouble(1);
                油管本期出库量 = Reader.GetDouble(2);           
            }
            Reader.Close();
            //套管
            //获得月计划
            string sql2 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料本期收入(@年度,@月份,2,原料供货单位.ID),dbo.供货原料期初库存(@年度,@月份,2,原料供货单位.ID),[dbo].[分厂原料本期发出](@年度,@月份,2,原料供货单位.ID,2),[dbo].[分厂原料本期发出](@年度,@月份,2,原料供货单位.ID,1) from 原料入出库 inner join 原料供货单位 on 原料供货单位.ID=原料入出库.单位ID where 原料ID=2 and 入出=0 and 日期 between @yc and @ym 
                 ";
            sql2 = sql2.Replace("@年度", this.Year0.SelectedValue);
            sql2 = sql2.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql2;
            Reader = Cmd.ExecuteReader();
            tNum = 0;
            while (Reader.Read())
            {
                套管供货单位[tNum] = Reader.GetString(0);
                套管个单位本期入库量[tNum] = Reader.GetDouble(1);
                套管个单位期初库存库量[tNum] = Reader.GetDouble(2);
                二分厂套管个单位本期出库量[tNum] = Reader.GetDouble(3);
                一分厂套管个单位本期出库量[tNum] = Reader.GetDouble(4);
                二分厂套管个单位本期出库量累计 += 二分厂套管个单位本期出库量[tNum];
                一分厂套管个单位本期出库量累计 += 一分厂套管个单位本期出库量[tNum];
                合计套管个单位本期出库量[tNum] = 二分厂套管个单位本期出库量[tNum] + 一分厂套管个单位本期出库量[tNum];

                tNum++;
            }
            Reader.Close();
            string sql3 = @"            
            select dbo.原料期初库存(@年度,@月份,2),dbo.原料本期收入(@年度,@月份,2),dbo.原料本期发出(@年度,@月份,2)";
            sql3 = sql3.Replace("@年度", this.Year0.SelectedValue);
            sql3 = sql3.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql3;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                套管期初库存量 = Reader.GetDouble(0);
                套管本期入库量 = Reader.GetDouble(1);
                套管本期出库量 = Reader.GetDouble(2);
            }
            Reader.Close();
            //获得月计划
            //油管接箍
            string sql4 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料本期收入(@年度,@月份,3,原料供货单位.ID),dbo.供货原料期初库存(@年度,@月份,3,原料供货单位.ID),[dbo].[分厂原料本期发出](@年度,@月份,3,原料供货单位.ID,3) from 原料入出库 inner join 原料供货单位 on 原料供货单位.ID=原料入出库.单位ID where 原料ID=3 and 入出=0 and 日期 between @yc and @ym 
                 ";
            sql4 = sql4.Replace("@年度", this.Year0.SelectedValue);
            sql4 = sql4.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql4;
            Reader = Cmd.ExecuteReader();
            yjgNum = 0;
            while (Reader.Read())
            {
                油管接箍供货单位[yjgNum] = Reader.GetString(0);
                油管接箍个单位本期入库量[yjgNum] = Reader.GetDouble(1);
                油管接箍个单位期初库存库量[yjgNum] = Reader.GetDouble(2);
                三分厂油管接箍个单位本期出库量[yjgNum] = Reader.GetDouble(3);
                三分厂油管接箍个单位本期出库量累计 += 三分厂油管接箍个单位本期出库量[yjgNum];
                合计油管接箍个单位本期出库量[yjgNum] = 三分厂油管接箍个单位本期出库量[yjgNum];
                yjgNum++;
            }
            Reader.Close();
            string sql5 = @"            
            select dbo.原料期初库存(@年度,@月份,3),dbo.原料本期收入(@年度,@月份,3),dbo.原料本期发出(@年度,@月份,3)";
            sql5 = sql5.Replace("@年度", this.Year0.SelectedValue);
            sql5 = sql5.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql5;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                油管接箍期初库存量 = Reader.GetDouble(0);
                油管接箍本期入库量 = Reader.GetDouble(1);
                油管接箍本期出库量 = Reader.GetDouble(2);
            }
            Reader.Close();
            //获得月计划
            //套管接箍
            string sql6 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料本期收入(@年度,@月份,4,原料供货单位.ID),dbo.供货原料期初库存(@年度,@月份,4,原料供货单位.ID),[dbo].[分厂原料本期发出](@年度,@月份,4,原料供货单位.ID,3) from 原料入出库 inner join 原料供货单位 on 原料供货单位.ID=原料入出库.单位ID where 原料ID=4 and 入出=0 and 日期 between @yc and @ym 
                 ";
            sql6 = sql6.Replace("@年度", this.Year0.SelectedValue);
            sql6 = sql6.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql6;
            Reader = Cmd.ExecuteReader();
            tjgNum = 0;
            while (Reader.Read())
            {
                套管接箍供货单位[tjgNum] = Reader.GetString(0);
                套管接箍个单位本期入库量[tjgNum] = Reader.GetDouble(1);
                套管接箍个单位期初库存库量[tjgNum] = Reader.GetDouble(2);
                三分厂套管接箍个单位本期出库量[tjgNum] = Reader.GetDouble(3);
                三分厂套管接箍个单位本期出库量累计 += 三分厂套管接箍个单位本期出库量[tjgNum];
                合计套管接箍个单位本期出库量[tjgNum] = 三分厂套管接箍个单位本期出库量[tjgNum];
                tjgNum++;
            }
            Reader.Close();
            string sql7 = @"            
            select dbo.原料期初库存(@年度,@月份,4),dbo.原料本期收入(@年度,@月份,4),dbo.原料本期发出(@年度,@月份,4)";
            sql7 = sql7.Replace("@年度", this.Year0.SelectedValue);
            sql7 = sql7.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql7;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                套管接箍期初库存量 = Reader.GetDouble(0);
                套管接箍本期入库量 = Reader.GetDouble(1);
                套管接箍本期出库量 = Reader.GetDouble(2);
            }
            Reader.Close();
            //待处理油管
            string sql8 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料待处理本期收入(@年度,@月份,1,原料供货单位.ID),dbo.供货原料待处理期末库存(@年度,@月份,1,原料供货单位.ID),[dbo].[分厂原料待处理本期发出](@年度,@月份,1,原料供货单位.ID,2),[dbo].[分厂原料待处理本期发出](@年度,@月份,1,原料供货单位.ID,5) from 原料异议库 inner join 原料供货单位 on 原料供货单位.ID=原料异议库.供货单位ID where 原料ID=1 and 已处理=0 and 日期 between @yc and @ym 
                 ";
            sql8 = sql8.Replace("@年度", this.Year0.SelectedValue);
            sql8 = sql8.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql8;
            Reader = Cmd.ExecuteReader();
            ydclNum = 0;
            while (Reader.Read())
            {
                待处理油管供货单位[ydclNum] = Reader.GetString(0);
                待处理油管个单位本期入库量[ydclNum] = 0;
                待处理油管个单位期末库存库量[ydclNum] = Reader.GetDouble(2);
                二分厂待处理油管个单位本期出库量[ydclNum] = Reader.GetDouble(3);
                五分厂待处理油管个单位本期出库量[ydclNum] = Reader.GetDouble(4);
                二分厂待处理油管个单位本期出库量累计 += 二分厂待处理油管个单位本期出库量[ydclNum];
                五分厂待处理油管个单位本期出库量累计 += 五分厂待处理油管个单位本期出库量[ydclNum];
                合计待处理油管个单位本期出库量[ydclNum] = 二分厂待处理油管个单位本期出库量[ydclNum] + 五分厂待处理油管个单位本期出库量[ydclNum];

                ydclNum++;
            }
            Reader.Close();
            string sql9 = @"            
            select dbo.待处理本期收入(@年度,@月份,1),dbo.待处理本期发出(@年度,@月份,1),dbo.待处理期末库存(@年度,@月份,1)";
            sql9 = sql9.Replace("@年度", this.Year0.SelectedValue);
            sql9 = sql9.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql9;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {                       
                待处理油管本期入库量 =0;
                待处理油管本期出库量 = Reader.GetDouble(1);
                待处理油管期末库存量 = Reader.GetDouble(2);  
            }
            Reader.Close();
            //待处理油管接箍
            string sql10 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料待处理本期收入(@年度,@月份,3,原料供货单位.ID),dbo.供货原料待处理期末库存(@年度,@月份,3,原料供货单位.ID),[dbo].[分厂原料待处理本期发出](@年度,@月份,3,原料供货单位.ID,3) from 原料异议库 inner join 原料供货单位 on 原料供货单位.ID=原料异议库.供货单位ID where 原料ID=3 and 已处理=0 and 日期 between @yc and @ym 
                 ";
            sql10 = sql10.Replace("@年度", this.Year0.SelectedValue);
            sql10 = sql10.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql10;
            Reader = Cmd.ExecuteReader();
            yjgdclNum = 0;
            while (Reader.Read())
            {
                待处理油管接箍供货单位[yjgdclNum] = Reader.GetString(0);
                待处理油管接箍个单位本期入库量[yjgdclNum] = 0;
                待处理油管接箍个单位期末库存库量[yjgdclNum] = Reader.GetDouble(2);
                三分厂待处理油管接箍个单位本期出库量[yjgdclNum] = Reader.GetDouble(3);
                三分厂待处理油管接箍个单位本期出库量累计 += 三分厂待处理油管接箍个单位本期出库量[yjgdclNum];
                合计待处理油管接箍个单位本期出库量[yjgdclNum] = 三分厂待处理油管接箍个单位本期出库量[yjgdclNum];

                yjgdclNum++;
            }
            Reader.Close();
            string sql11 = @"            
            select dbo.待处理本期收入(@年度,@月份,3),dbo.待处理本期发出(@年度,@月份,3),dbo.待处理期末库存(@年度,@月份,3)";
            sql11 = sql11.Replace("@年度", this.Year0.SelectedValue);
            sql11 = sql11.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql11;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                待处理油管接箍本期入库量 = 0;
                待处理油管接箍本期出库量 = Reader.GetDouble(1);
                待处理油管接箍期末库存量 = Reader.GetDouble(2);
            }
            Reader.Close();
            //------------------------------------------------
            //待处理套管
            string sql12 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料待处理本期收入(@年度,@月份,2,原料供货单位.ID),dbo.供货原料待处理期末库存(@年度,@月份,2,原料供货单位.ID),[dbo].[分厂原料待处理本期发出](@年度,@月份,2,原料供货单位.ID,2),[dbo].[分厂原料待处理本期发出](@年度,@月份,2,原料供货单位.ID,1) from 原料异议库 inner join 原料供货单位 on 原料供货单位.ID=原料异议库.供货单位ID where 原料ID=2 and 已处理=0 and 日期 between @yc and @ym 
                 ";
            sql12 = sql12.Replace("@年度", this.Year0.SelectedValue);
            sql12 = sql12.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql12;
            Reader = Cmd.ExecuteReader();
            tdclNum = 0;
            while (Reader.Read())
            {
                待处理套管供货单位[tdclNum] = Reader.GetString(0);
                待处理套管个单位本期入库量[tdclNum] = 0;
                待处理套管个单位期末库存库量[tdclNum] = Reader.GetDouble(2);
                二分厂待处理套管个单位本期出库量[tdclNum] = Reader.GetDouble(3);
                一分厂待处理套管个单位本期出库量[tdclNum] = Reader.GetDouble(4);
                二分厂待处理套管个单位本期出库量累计 += 二分厂待处理套管个单位本期出库量[tdclNum];
                一分厂待处理套管个单位本期出库量累计 += 一分厂待处理套管个单位本期出库量[tdclNum];
                合计待处理套管个单位本期出库量[tdclNum] = 二分厂待处理套管个单位本期出库量[tdclNum] + 一分厂待处理套管个单位本期出库量[tdclNum];

                tdclNum++;
            }
            Reader.Close();
            string sql13 = @"            
            select dbo.待处理本期收入(@年度,@月份,2),dbo.待处理本期发出(@年度,@月份,2),dbo.待处理期末库存(@年度,@月份,2)";
            sql13 = sql13.Replace("@年度", this.Year0.SelectedValue);
            sql13 = sql13.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql13;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                待处理套管本期入库量 = 0;
                待处理套管本期出库量 = Reader.GetDouble(1);
                待处理套管期末库存量 = Reader.GetDouble(2);
            }
            Reader.Close();
            //待处理套管接箍
            string sql14 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料待处理本期收入(@年度,@月份,4,原料供货单位.ID),dbo.供货原料待处理期末库存(@年度,@月份,4,原料供货单位.ID),[dbo].[分厂原料待处理本期发出](@年度,@月份,4,原料供货单位.ID,3) from 原料异议库 inner join 原料供货单位 on 原料供货单位.ID=原料异议库.供货单位ID where 原料ID=4 and 已处理=0 and 日期 between @yc and @ym 
                 ";
            sql14 = sql14.Replace("@年度", this.Year0.SelectedValue);
            sql14 = sql14.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql14;
            Reader = Cmd.ExecuteReader();
            tjgdclNum = 0;
            while (Reader.Read())
            {
                待处理套管接箍供货单位[tjgdclNum] = Reader.GetString(0);
                待处理套管接箍个单位本期入库量[tjgdclNum] = 0;
                待处理套管接箍个单位期末库存库量[tjgdclNum] = Reader.GetDouble(2);
                三分厂待处理套管接箍个单位本期出库量[tjgdclNum] = Reader.GetDouble(3);
                三分厂待处理套管接箍个单位本期出库量累计 += 三分厂待处理套管接箍个单位本期出库量[tjgdclNum];
                合计待处理套管接箍个单位本期出库量[tjgdclNum] = 三分厂待处理套管接箍个单位本期出库量[tjgdclNum];

                tjgdclNum++;
            }
            Reader.Close();
            string sql15 = @"            
            select dbo.待处理本期收入(@年度,@月份,4),dbo.待处理本期发出(@年度,@月份,4),dbo.待处理期末库存(@年度,@月份,4)";
            sql15 = sql15.Replace("@年度", this.Year0.SelectedValue);
            sql15 = sql15.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql15;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                待处理套管接箍本期入库量 = 0;
                待处理套管接箍本期出库量 = Reader.GetDouble(1);
                待处理套管接箍期末库存量 = Reader.GetDouble(2);
            }
            Reader.Close();
            //套管N80
            string sql16 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料本期收入(@年度,@月份,102,原料供货单位.ID),dbo.供货原料期初库存(@年度,@月份,102,原料供货单位.ID),[dbo].[分厂原料本期发出](@年度,@月份,102,原料供货单位.ID,2),[dbo].[分厂原料本期发出](@年度,@月份,102,原料供货单位.ID,1) from 原料入出库 inner join 原料供货单位 on 原料供货单位.ID=原料入出库.单位ID where 原料ID=102 and 入出=0 and 日期 between @yc and @ym 
                 ";
            sql16 = sql16.Replace("@年度", this.Year0.SelectedValue);
            sql16 = sql16.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql16;
            Reader = Cmd.ExecuteReader();
            tn80Num = 0;
            while (Reader.Read())
            {
                套管N80供货单位[tn80Num] = Reader.GetString(0);
                套管N80个单位本期入库量[tn80Num] = Reader.GetDouble(1);
                套管N80个单位期初库存库量[tn80Num] = Reader.GetDouble(2);
                二分厂套管N80个单位本期出库量[tn80Num] = Reader.GetDouble(3);
                一分厂套管N80个单位本期出库量[tNum] = Reader.GetDouble(4);
                二分厂套管N80个单位本期出库量累计 += 二分厂套管N80个单位本期出库量[tn80Num];
                一分厂套管N80个单位本期出库量累计 += 一分厂套管N80个单位本期出库量[tn80Num];
                合计套管N80个单位本期出库量[tn80Num] = 二分厂套管N80个单位本期出库量[tn80Num] + 一分厂套管N80个单位本期出库量[tn80Num];

                tn80Num++;
            }
            Reader.Close();
            string sql17 = @"            
            select dbo.原料期初库存(@年度,@月份,102),dbo.原料本期收入(@年度,@月份,102),dbo.原料本期发出(@年度,@月份,102)";
            sql17 = sql17.Replace("@年度", this.Year0.SelectedValue);
            sql17 = sql17.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql17;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                套管N80期初库存量 = Reader.GetDouble(0);
                套管N80本期入库量 = Reader.GetDouble(1);
                套管N80本期出库量 = Reader.GetDouble(2);
            }          
            Reader.Close();
            //待处理套管N80
            string sql18 = @"
                 declare @yc smalldatetime
                 declare @ym smalldatetime                
                 select @yc=起始日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=1
                 select @ym=截止日期 from 生产月设置 where 分厂=0 and 年度=@年度 and 月份=@月份
                 select distinct 名称,dbo.供货原料待处理本期收入(@年度,@月份,102,原料供货单位.ID),dbo.供货原料待处理期末库存(@年度,@月份,102,原料供货单位.ID),[dbo].[分厂原料待处理本期发出](@年度,@月份,102,原料供货单位.ID,2),[dbo].[分厂原料待处理本期发出](@年度,@月份,102,原料供货单位.ID,1) from 原料异议库 inner join 原料供货单位 on 原料供货单位.ID=原料异议库.供货单位ID where 原料ID=102 and 已处理=0 and 日期 between @yc and @ym 
                 ";
            sql18 = sql18.Replace("@年度", this.Year0.SelectedValue);
            sql18 = sql18.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql18;
            Reader = Cmd.ExecuteReader();
            tn80dclNum = 0;
            while (Reader.Read())
            {
                待处理套管N80供货单位[tn80dclNum] = Reader.GetString(0);
                待处理套管N80个单位本期入库量[tn80dclNum] = 0;
                待处理套管N80个单位期末库存库量[tn80dclNum] = Reader.GetDouble(2);
                二分厂待处理套管N80个单位本期出库量[tn80dclNum] = Reader.GetDouble(3);
                一分厂待处理套管N80个单位本期出库量[tn80dclNum] = Reader.GetDouble(4);
                二分厂待处理套管N80个单位本期出库量累计 += 二分厂待处理套管N80个单位本期出库量[tn80dclNum];
                一分厂待处理套管个单位本期出库量累计 += 一分厂待处理套管N80个单位本期出库量[tn80dclNum];
                合计待处理套管N80个单位本期出库量[tn80dclNum] = 二分厂待处理套管N80个单位本期出库量[tn80dclNum] + 一分厂待处理套管N80个单位本期出库量[tn80dclNum];

                tdclNum++;
            }
            Reader.Close();
            string sql19 = @"            
            select dbo.待处理本期收入(@年度,@月份,102),dbo.待处理本期发出(@年度,@月份,102),dbo.待处理期末库存(@年度,@月份,102)";
            sql19 = sql19.Replace("@年度", this.Year0.SelectedValue);
            sql19= sql19.Replace("@月份", this.Month0.SelectedValue);
            Cmd.CommandText = sql19;
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                待处理套管N80本期入库量 = 0;
                待处理套管N80本期出库量 = Reader.GetDouble(1);
                待处理套管N80期末库存量 = Reader.GetDouble(2);
            }
            Reader.Close();
            Reader.Dispose();
            Cmd.Dispose();
            Conn.Dispose();
        }

        protected void Button_To_Click(object sender, EventArgs e)
        {
            Response.Charset = "utf-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "application/ms-excel";
            Response.AddHeader("content-disposition", "attachment; filename=\"" + Server.UrlEncode("原料收拨平衡表") + ".xls\"");
            string part1 = @"<html xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:x='urn:schemas-microsoft-com:office:excel'
xmlns='http://www.w3.org/TR/REC-html40'>
<meta http-equiv=Content-Type content='text/html; charset=utf-8'>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Chinese User</o:Author>
  <o:LastAuthor>Chinese User</o:LastAuthor>
  <o:Created>2010-12-18T02:59:00Z</o:Created>
  <o:LastSaved>2010-12-18T02:59:27Z</o:LastSaved>
  <o:Company>Chinese ORG</o:Company>
  <o:Version>11.9999</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<style>
<!--table
	{mso-displayed-decimal-separator:'\.';
	mso-displayed-thousand-separator:'\,';}
@page
	{margin:.24in .39in .24in .47in;
	mso-header-margin:.59in;
	mso-footer-margin:.55in;
	mso-page-orientation:landscape;}
.font0
	{color:windowtext;
	font-size:12.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;}
tr
	{mso-height-source:auto;
	mso-ruby-visibility:none;}
col
	{mso-width-source:auto;
	mso-ruby-visibility:none;}
br
	{mso-data-placement:same-cell;}
.style0
	{mso-number-format:General;
	text-align:general;
	vertical-align:middle;
	white-space:nowrap;
	mso-rotate:0;
	mso-background-source:auto;
	mso-pattern:auto;
	color:windowtext;
	font-size:12.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;
	border:none;
	mso-protection:locked visible;
	mso-style-name:常规;
	mso-style-id:0;}
td
	{mso-style-parent:style0;
	padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:12.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;
	mso-number-format:General;
	text-align:general;
	vertical-align:middle;
	border:none;
	mso-background-source:auto;
	mso-pattern:auto;
	mso-protection:locked visible;
	white-space:nowrap;
	mso-rotate:0;}
.xl24
	{mso-style-parent:style0;
	font-size:20.0pt;
	text-align:center;}
.xl25
	{mso-style-parent:style0;
	font-size:11.0pt;}
.xl26
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:left;}
.xl27
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:none;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:none;}
.xl28
	{mso-style-parent:style0;
	font-size:11.0pt;
	border-top:none;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:none;}
.xl29
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:none;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:none;
	white-space:nowrap;
	mso-text-control:shrinktofit;}
.xl30
	{mso-style-parent:style0;
	font-size:18.0pt;
	text-align:center;}
.xl31
	{mso-style-parent:style0;
	font-size:11.0pt;
	mso-number-format:'Long Date';
	text-align:center;
	border-top:none;
	border-right:none;
	border-bottom:.5pt solid windowtext;
	border-left:none;}
.xl32
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:.5pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:none;
	border-left:.5pt solid windowtext;}
.xl33
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:none;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:.5pt solid windowtext;}
.xl34
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:none;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid black;
	border-left:.5pt solid windowtext;}
.xl35
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:.5pt solid windowtext;
	border-right:none;
	border-bottom:.5pt solid windowtext;
	border-left:none;}
.xl36
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:.5pt solid windowtext;
	border-right:none;
	border-bottom:.5pt solid windowtext;
	border-left:.5pt solid windowtext;}
.xl37
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border-top:.5pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:none;}
.xl38
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border:.5pt solid windowtext;
	white-space:nowrap;
	mso-text-control:shrinktofit;}
.xl39
	{mso-style-parent:style0;
	font-size:11.0pt;
	mso-number-format:'0\.000_ ';
	text-align:center;
	border:.5pt solid windowtext;}
.xl40
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border:.5pt solid windowtext;}
.xl41
	{mso-style-parent:style0;
	text-align:center;
	white-space:nowrap;
	mso-text-control:shrinktofit;}
.xl42
	{mso-style-parent:style0;
	font-size:18.0pt;
	text-align:center;
	white-space:nowrap;
	mso-text-control:shrinktofit;}
.xl43
	{mso-style-parent:style0;
	font-size:11.0pt;
	border:.5pt solid windowtext;}
.xl46
	{mso-style-parent:style0;
	border:.5pt solid windowtext;}
.xl47
	{mso-style-parent:style0;
	font-size:11.0pt;
	text-align:center;
	border:.5pt solid windowtext;}
ruby
	{ruby-align:left;}
rt
	{color:windowtext;
	font-size:9.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:宋体;
	mso-generic-font-family:auto;
	mso-font-charset:134;
	mso-char-type:none;
	display:none;}
-->
</style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet1</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:Print>
      <x:ValidPrinterInfo/>
      <x:PaperSizeIndex>9</x:PaperSizeIndex>
      <x:HorizontalResolution>600</x:HorizontalResolution>
      <x:VerticalResolution>600</x:VerticalResolution>
     </x:Print>
     <x:PageBreakZoom>60</x:PageBreakZoom>
     <x:Selected/>
     <x:TopRowVisible>12</x:TopRowVisible>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveRow>29</x:ActiveRow>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet2</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet3</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:WindowHeight>8100</x:WindowHeight>
  <x:WindowWidth>11700</x:WindowWidth>
  <x:WindowTopX>240</x:WindowTopX>
  <x:WindowTopY>90</x:WindowTopY>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml><![endif]-->
</head>

<body link=blue vlink=purple>

<table x:str border=0 cellpadding=0 cellspacing=0 width=1029 style='border-collapse:
 collapse;table-layout:fixed;width:774pt'>
 <col width=85 style='mso-width-source:userset;mso-width-alt:2720;width:64pt'>
 <col width=42 style='mso-width-source:userset;mso-width-alt:1344;width:32pt'>
 <col width=93 style='mso-width-source:userset;mso-width-alt:2976;width:70pt'>
 <col width=85 style='mso-width-source:userset;mso-width-alt:2720;width:64pt'>
 <col width=34 style='mso-width-source:userset;mso-width-alt:1088;width:26pt'>
 <col width=85 style='mso-width-source:userset;mso-width-alt:2720;width:64pt'>
 <col width=100 style='mso-width-source:userset;mso-width-alt:3200;width:75pt'>
 <col width=4 style='mso-width-source:userset;mso-width-alt:128;width:3pt'>
 <col width=87 style='mso-width-source:userset;mso-width-alt:2784;width:65pt'>
 <col width=79 style='mso-width-source:userset;mso-width-alt:2528;width:59pt'>
 <col width=74 style='mso-width-source:userset;mso-width-alt:2368;width:56pt'>
 <col width=77 style='mso-width-source:userset;mso-width-alt:2464;width:58pt'>
 <col width=85 style='mso-width-source:userset;mso-width-alt:2720;width:64pt'>
 <col width=99 style='mso-width-source:userset;mso-width-alt:3168;width:74pt'>
 <tr height=28 style='mso-height-source:userset;height:21.0pt'>
  <td colspan=14 height=28 class=xl30 width=1029 style='height:21.0pt;
  width:774pt'>（2010年11月）原料收拨平衡表<font class='font0'>（技术处）</font></td>
 </tr>
 <tr height=0 style='display:none;mso-height-source:userset;mso-height-alt:
  150'>
  <td height=0 colspan=14 class=xl24 style='mso-ignore:colspan'></td>
 </tr>
 <tr height=17 style='mso-height-source:userset;height:12.75pt'>
  <td height=17 class=xl26 colspan=3 style='height:12.75pt;mso-ignore:colspan'>填报单位：物料中心</td>
  <td class=xl26></td>
  <td colspan=8 class=xl25 style='mso-ignore:colspan'></td>
  <td colspan=2 class=xl31 x:num='40510'>2010年11月28日</td>
 </tr>
 <tr height=16 style='mso-height-source:userset;height:12.0pt'>
  <td rowspan=2 height=32 class=xl32 style='border-bottom:.5pt solid black;
  height:24.0pt'>物资名称</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black'>钢级</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black'>规格</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black'>供货单位</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black'>单位</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black'>期初库存</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black'>本期外购</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black'>　</td>
  <td colspan=5 class=xl36 style='border-right:.5pt solid black;border-left:
  none'>消 耗 量</td>
  <td rowspan=2 class=xl32 style='border-bottom:.5pt solid black;border-top:
  none'>期末库存</td>
 </tr>
 <tr height=16 style='mso-height-source:userset;height:12.0pt'>
  <td height=16 class=xl27 style='height:12.0pt'>一分厂</td>
  <td class=xl27>二分厂</td>
  <td class=xl27>三分厂</td>
  <td class=xl27>五分厂</td>
  <td class=xl27>合计</td>
 </tr> ";
            Response.Write(part1);
             //油管
             for (int i = 0; i < yNum; i++)
             {
                 if (i == 0)
                 {
                    Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                    Response.Write("<td height=22 height=22 class=xl33 style='height:17.1pt' align=center>油管</td>");
                    Response.Write("<td class=xl28  align=center>J55</td>");
                    Response.Write("<td class=xl29 >73.02×5.51</td>");
                    Response.Write("<td class=xl27 >" + 油管供货单位[i] + "</td>");
                    Response.Write("<td class=xl27 >t</td>");
                    Response.Write("<td class=xl27 >" + 油管个单位期初库存库量[i] + "</td>");
                    Response.Write("<td class=xl27 >" + 油管个单位本期入库量[i] + "</td>");
                    Response.Write("<td class=xl27 ></td>");
                    Response.Write("<td class=xl27 ></td>");
                    Response.Write("<td class=xl27 >" + 二分厂油管个单位本期出库量[i] + "</td>");
                    Response.Write("<td class=xl27 ></td>");
                    Response.Write("<td class=xl27 >" + 五分厂油管个单位本期出库量[i] + "</td>");
                    Response.Write("<td class=xl27 >" + 合计油管个单位本期出库量[i] + "</td>");
                    Response.Write("<td class=xl27 >" + (油管个单位期初库存库量[i] + 油管个单位本期入库量[i] - 合计油管个单位本期出库量[i]) + "</td></tr>"); 
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 油管供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 油管个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 油管个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 二分厂油管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 五分厂油管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 合计油管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (油管个单位期初库存库量[i] + 油管个单位本期入库量[i] - 合计油管个单位本期出库量[i]) + "</td></tr>"); 
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + 油管期初库存量 + "</td>");
             Response.Write("<td class=xl27 >" + 油管本期入库量 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 二分厂油管个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 五分厂油管个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 >" + 油管本期出库量 + "</td>");
             Response.Write("<td class=xl27>" + (油管期初库存量 + 油管本期入库量 - 油管本期出库量) + "</td></tr>");

             //套管
             for (int i = 0; i < tNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt' align=center>套管</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >139.7×7.75</td>");
                     Response.Write("<td class=xl27 >" + 套管供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 套管个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 套管个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (套管个单位期初库存库量[i] + 套管个单位本期入库量[i] - 合计套管个单位本期出库量[i]) + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 套管供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 套管个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 套管个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (套管个单位期初库存库量[i] + 套管个单位本期入库量[i] - 合计套管个单位本期出库量[i]) + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + 套管期初库存量 + "</td>");
             Response.Write("<td class=xl27 >" + 套管本期入库量 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 一分厂套管个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 >" + 二分厂套管个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 套管本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + (套管期初库存量 + 套管本期入库量 - 套管本期出库量) + "</td></tr>");

             //油管接箍
             for (int i = 0; i < yjgNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none' align=center>油管接箍</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >88.9×12.5</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (油管接箍个单位期初库存库量[i] + 油管接箍个单位本期入库量[i] - 合计油管接箍个单位本期出库量[i]) + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 油管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (油管接箍个单位期初库存库量[i] + 油管接箍个单位本期入库量[i] - 合计油管接箍个单位本期出库量[i]) + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + 油管接箍期初库存量 + "</td>");
             Response.Write("<td class=xl27 >" + 油管接箍本期入库量 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 三分厂油管接箍个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 油管接箍本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + (油管接箍期初库存量 + 油管接箍本期入库量 - 油管接箍本期出库量) + "</td></tr>");

             //套管接箍
             for (int i = 0; i < tjgNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none' align=center>套管接箍</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >88.9×12.5</td>");
                     Response.Write("<td class=xl27 >" + 套管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 套管接箍个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 套管接箍个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (套管接箍个单位期初库存库量[i] + 套管接箍个单位本期入库量[i] - 合计套管接箍个单位本期出库量[i]) + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 套管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 套管接箍个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 套管接箍个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (套管接箍个单位期初库存库量[i] + 套管接箍个单位本期入库量[i] - 合计套管接箍个单位本期出库量[i]) + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + 套管接箍期初库存量 + "</td>");
             Response.Write("<td class=xl27 >" + 套管接箍本期入库量 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 三分厂套管接箍个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 套管接箍本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + (套管接箍期初库存量 + 套管接箍本期入库量 - 套管接箍本期出库量) + "</td></tr>");
             //油管接箍 
            for (int i = 0; i < yjgNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none' align=center>油管接箍</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >88.9×12.5</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (油管接箍个单位期初库存库量[i] + 油管接箍个单位本期入库量[i] - 合计油管接箍个单位本期出库量[i]) + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 油管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 油管接箍个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (油管接箍个单位期初库存库量[i] + 油管接箍个单位本期入库量[i] - 合计油管接箍个单位本期出库量[i]) + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt;border-top:none'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + 油管接箍期初库存量 + "</td>");
             Response.Write("<td class=xl27 >" + 油管接箍本期入库量 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 三分厂油管接箍个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 油管接箍本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + (油管接箍期初库存量 + 油管接箍本期入库量 - 油管接箍本期出库量) + "</td></tr>");


            //待处理油管,油管接箍

             string part2 = @"<tr height=30 style='height:22.5pt'>
  <td colspan=14 height=30 class=xl42 style='height:22.5pt'>（2010年11月）原料收拨平衡表（技术处）</td>
 </tr>
 <tr height=19 style='height:14.25pt'>
  <td height=19 class=xl26 colspan=3 style='height:14.25pt;mso-ignore:colspan'>填报单位：物料中心</td>
  <td class=xl26></td>
  <td colspan=8 class=xl25 style='mso-ignore:colspan'></td>
  <td colspan=2 class=xl41>2010年11月28日</td>
 </tr>
 <tr height=19 style='height:14.25pt'>
  <td rowspan=2 height=38 class=xl38 style='height:28.5pt'>物资名称</td>
  <td rowspan=2 class=xl38>钢级</td>
  <td rowspan=2 class=xl38>规格</td>
  <td rowspan=2 class=xl38>供货单位</td>
  <td rowspan=2 class=xl38>单位</td>
  <td rowspan=2 class=xl38>期初库存</td>
  <td rowspan=2 class=xl38>本期外购</td>
  <td rowspan=2 class=xl38>　</td>
  <td colspan=5 class=xl38 style='border-left:none'>消 耗 量</td>
  <td rowspan=2 class=xl38>期末库存</td>
 </tr>
 <tr height=19 style='height:14.25pt'>
  <td height=19 class=xl39 style='height:14.25pt;border-top:none;border-left:
  none'>一分厂</td>
  <td class=xl40 style='border-top:none;border-left:none'>二分厂</td>
  <td class=xl40 style='border-top:none;border-left:none'>三分厂</td>
  <td class=xl40 style='border-top:none;border-left:none'>五分厂</td>
  <td class=xl38 style='border-top:none;border-left:none'>合计</td>
 </tr>";
            Response.Write(part2);   
            //待处理油管
             for (int i = 0; i < ydclNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt' align=center>待处理油管</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >73.02×5.51</td>");
                     Response.Write("<td class=xl27 >" + 待处理油管供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理油管个单位期末库存库量[i] + 合计待处理油管个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >"+二分厂待处理油管个单位本期出库量[i]+"</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >"+五分厂待处理油管个单位本期出库量[i]+"</td>");
                     Response.Write("<td class=xl27 >" + 合计待处理油管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理油管个单位期末库存库量[i] + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 待处理油管供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理油管个单位期末库存库量[i] + 合计待处理油管个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >"+二分厂待处理油管个单位本期出库量[i]+"</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >"+五分厂待处理油管个单位本期出库量[i]+"</td>");
                     Response.Write("<td class=xl27 >" + 合计待处理油管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理油管个单位期末库存库量[i]+ "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >"+(待处理油管期末库存量 + 待处理油管本期出库量 - 待处理油管本期入库量) + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >"+二分厂待处理油管个单位本期出库量累计 +"</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >"+五分厂待处理油管个单位本期出库量累计+"</td>");
             Response.Write("<td class=xl27 >" + 待处理油管本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + 待处理油管期末库存量 + "</td></tr>");
             //待处理油管接箍
             for (int i = 0; i < yjgdclNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt' align=center>待处理油管接箍</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >88.9×12.5</td>");
                     Response.Write("<td class=xl27 >" + 待处理油管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理油管接箍个单位期末库存库量[i] + 合计待处理油管接箍个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂待处理油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理油管接箍个单位期末库存库量[i] + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 待处理油管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理油管接箍个单位期末库存库量[i] + 合计待处理油管接箍个单位本期出库量[i])+ "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂待处理油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理油管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理油管接箍个单位期末库存库量 + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl46 style='border-top:none;border-left:none'></td>");
             Response.Write("<td class=xl47 style='border-top:none;border-left:none'></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" +(待处理油管接箍期末库存量 + 待处理油管接箍本期出库量 - 待处理油管接箍本期入库量) + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 三分厂待处理油管接箍个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 待处理油管接箍本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + 待处理油管接箍期末库存量 + "</td></tr>");

             //待处理套管,套管接箍
             
             Response.Write(part2);
             //待处理套管
             for (int i = 0; i < tdclNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt' align=center>待处理套管</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >139.7×7.72</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理套管个单位期末库存库量[i] + 合计待处理套管个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂待处理套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂待处理套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管个单位期末库存库量[i] + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 待处理套管供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理套管个单位期末库存库量[i] + 合计待处理套管个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂待处理套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂待处理套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理套管个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管个单位期末库存库量[i] + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + (待处理套管期末库存量 + 待处理套管本期出库量 - 待处理套管本期入库量) + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 一分厂待处理套管个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 >" + 二分厂待处理套管个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 待处理套管本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + 待处理套管期末库存量 + "</td></tr>");
             //待处理套管接箍
             for (int i = 0; i < tjgdclNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt' align=center>待处理套管接箍</td>");
                     Response.Write("<td class=xl28  align=center>J55</td>");
                     Response.Write("<td class=xl29 >153.67×14.5</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理套管接箍个单位期末库存库量[i] + 合计待处理套管接箍个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂待处理套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管接箍个单位期末库存库量[i] + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 待处理套管接箍供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理套管接箍个单位期末库存库量[i] + 合计待处理套管接箍个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 三分厂待处理套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理套管接箍个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管接箍个单位期末库存库量 + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl46 style='border-top:none;border-left:none'></td>");
             Response.Write("<td class=xl47 style='border-top:none;border-left:none'></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + (待处理套管接箍期末库存量 + 待处理套管接箍本期出库量 - 待处理套管接箍本期入库量) + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 三分厂待处理套管接箍个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 待处理套管接箍本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + 待处理套管接箍期末库存量 + "</td></tr>");
            //套管N80
             Response.Write(part2);
        
             for (int i = 0; i < tn80Num; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt' align=center>套管</td>");
                     Response.Write("<td class=xl28  align=center>N80</td>");
                     Response.Write("<td class=xl29 >139.7×7.72</td>");
                     Response.Write("<td class=xl27 >" + 套管N80供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 套管N80个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 套管N80个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (套管N80个单位期初库存库量[i] + 套管N80个单位本期入库量[i] - 合计套管N80个单位本期出库量[i]) + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 套管N80供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + 套管N80个单位期初库存库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 套管N80个单位本期入库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + (套管N80个单位期初库存库量[i] + 套管N80个单位本期入库量[i] - 合计套管N80个单位本期出库量[i]) + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + 套管N80期初库存量 + "</td>");
             Response.Write("<td class=xl27 >" + 套管N80本期入库量 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 一分厂套管N80个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 >" + 二分厂套管N80个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 套管N80本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + (套管N80期初库存量 + 套管N80本期入库量 - 套管N80本期出库量) + "</td></tr>");
             //待处理套管N80
             for (int i = 0; i < tn80dclNum; i++)
             {
                 if (i == 0)
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt' align=center>待处理套管</td>");
                     Response.Write("<td class=xl28  align=center>N80</td>");
                     Response.Write("<td class=xl29 >139.7×7.72</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管N80供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理套管N80个单位期末库存库量[i] + 合计待处理套管N80个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂待处理套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂待处理套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管N80个单位期末库存库量[i] + "</td></tr>");
                 }
                 else
                 {
                     Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
                     Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
                     Response.Write("<td class=xl28 ></td>");
                     Response.Write("<td class=xl29 ></td>");
                     Response.Write("<td class=xl27 >" + 待处理套管N80供货单位[i] + "</td>");
                     Response.Write("<td class=xl27 >t</td>");
                     Response.Write("<td class=xl27 >" + (待处理套管N80个单位期末库存库量[i] + 合计待处理套管N80个单位本期出库量[i]) + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 一分厂待处理套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 二分厂待处理套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 ></td>");
                     Response.Write("<td class=xl27 >" + 合计待处理套管N80个单位本期出库量[i] + "</td>");
                     Response.Write("<td class=xl27 >" + 待处理套管N80个单位期末库存库量[i] + "</td></tr>");
                 }
             }
             Response.Write("<tr height=22 style='mso-height-source:userset;height:17.1pt'>");
             Response.Write("<td height=22 class=xl33 style='height:17.1pt'></td>");
             Response.Write("<td class=xl28 ></td>");
             Response.Write("<td class=xl29 ></td>");
             Response.Write("<td class=xl27 >小计</td>");
             Response.Write("<td class=xl27 >t</td>");
             Response.Write("<td class=xl27 >" + (待处理套管N80期末库存量 + 待处理套管N80本期出库量 - 待处理套管N80本期入库量) + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 一分厂待处理套管N80个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 >" + 二分厂待处理套管N80个单位本期出库量累计 + "</td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 ></td>");
             Response.Write("<td class=xl27 >" + 待处理套管N80本期出库量 + "</td>");
             Response.Write("<td class=xl27 >" + 待处理套管N80期末库存量 + "</td></tr>");
             string part0 = @"<![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=73 style='width:55pt'></td>
  <td width=63 style='width:47pt'></td>
  <td width=93 style='width:70pt'></td>
  <td width=85 style='width:64pt'></td>
  <td width=34 style='width:26pt'></td>
  <td width=85 style='width:64pt'></td>
  <td width=100 style='width:75pt'></td>
  <td width=4 style='width:3pt'></td>
  <td width=87 style='width:65pt'></td>
  <td width=79 style='width:59pt'></td>
  <td width=74 style='width:56pt'></td>
  <td width=77 style='width:58pt'></td>
  <td width=85 style='width:64pt'></td>
  <td width=99 style='width:74pt'></td>
 </tr>
 <![endif]>
</table>";



             Response.Write(part0);
             Response.End();
        }
    }
}
